import {NgModule, SkipSelf, Optional} from '@angular/core';
import {SharedModule} from '../shared/shared.module';
// import {HttpModule} from '@angular/http';
import {HttpClientModule} from '@angular/common/http';
import {HeaderComponent} from './header/header.component';
import {FooterComponent} from './footer/footer.component';
import {SidebarComponent} from './sidebar/sidebar.component';
import {MatIconRegistry} from '@angular/material';
import {DomSanitizer} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {loadSvgResources} from '../util/svg.util';
import 'hammerjs';
@NgModule({
  imports: [
    HttpClientModule,
    SharedModule,
    BrowserAnimationsModule,
  ],
  exports: [
    HeaderComponent,
    FooterComponent,
    SidebarComponent,
    SharedModule,
  ],
  declarations: [HeaderComponent, FooterComponent, SidebarComponent]
})
export class CoreModule {
  // 只加载一次
  constructor(@Optional() @SkipSelf() parent: CoreModule,
              iconRegistry: MatIconRegistry,
              sanitizer: DomSanitizer) {
    if (parent) {
      throw new Error('模块已经存在,不能再次加载!');
    }
    loadSvgResources(iconRegistry, sanitizer);
  }
}

